package com.kemai.designmode.ui
import android.os.Bundle
import com.kemai.common.adapter.ItemClickListener
import com.kemai.common.ui.BaseActivity
import com.kemai.designmode.R
import com.kemai.designmode.singleton.HungerSingleInstance
import com.kemai.designmode.singleton.LazySingleInstance
//单例模式调用（保证对象在内存中只有一份实例）
class SingleTonActivity : BaseActivity(), ItemClickListener {
    private val studyContent = arrayOf("饿汉式","懒汉式")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_common_content)
        findViewById()
        setTiTle("单例模式")
        setAdapterContent(studyContent,SingleTonActivity@this,SingleTonActivity@this)
    }

    override fun itemClick(position: Int) {

      when(position){

          0->{//饿汉时
              HungerSingleInstance.hungerTypeMethod()
          }
          1->{//懒汉式
             LazySingleInstance.getInstance()?.getLazySingleInstance()
          }
      }
    }

}